﻿@model IEnumerable<CubicFWNet.Data.Models.LogInLog>

@{
    ViewBag.Title = "系统日志";
}

<section class="content-header">
    <h1>
        系统日志
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index","Home")">首页</a></li>
        <li class="active"><a href="@Url.Action("Index","LogInlog")">系统日志</a></li>
    </ol>
</section>

<section class="content">
    <div class="row">
        <div class="col-sm-12">
            <div class="box box-solid">
                <div class="box-nav clearfix">
                    <div class="col-sm-12 col-md-9">
                        <div class="btn-group" id="time_horizon">
                            <input type="hidden" value="@ViewBag.TimeType" id="timeType" />
                            <button type="button" class="btn btn-default" data-value="1">今天</button>
                            <button type="button" class="btn btn-default active" data-value="2">近7天</button>
                            <button type="button" class="btn btn-default" data-value="3">近1个月</button>
                            <button type="button" class="btn btn-default" data-value="4">近3个月</button>
                            <button id="removelog" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_removelog()"><i class="fa fa-eraser"></i>清空日志</button>
                        </div>
                    </div>
                    <div class="col-sm-12 col-md-3">
                        <div class="input-group">
                            <input id="filter" type="text" value="@ViewBag.KeyWord" class="form-control form-control-static" placeholder="请输入要查询关键字">
                            <span class="input-group-btn">
                                <button id="btn_search" type="button" class="btn  btn-primary"><i class="fa fa-search"></i></button>
                            </span>
                        </div>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body">
                    <table class="footable table table-stripped table-bordered table-hover" id="footable" data-page-size="20" data-filter=#filter>
                        <thead>
                            <tr>
                                <th>
                                    @Html.DisplayNameFor(model => model.Time)
                                </th>
                                <th>
                                    @Html.DisplayNameFor(model => model.UserName)
                                </th>
                                <th data-hide="phone,tablet">
                                    @Html.DisplayNameFor(model => model.RealName)
                                </th>
                                <th data-hide="phone,tablet">
                                    @Html.DisplayNameFor(model => model.Type)
                                </th>
                                <th data-hide="phone,tablet">
                                    @Html.DisplayNameFor(model => model.IPAddress)
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            @if (null != Model)
                            {
                                foreach (var item in Model)
                                {
                                    <tr>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.Time)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.UserName)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.RealName)
                                        </td>
                                        <td>
                                            @Html.DisplayFor(modelItem => item.Type)
                                        </td>
                                        <td>
                                            @item.IPAddress;@item.IPAddressName
                                        </td>
                                    </tr>
                                }
                            }
                        </tbody>
                        <tfoot>
                            <tr>
                                <td colspan="5">
                                    <ul class="pagination1 pagination pull-right"></ul>
                                </td>
                            </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>

<div class="modal" id="removeDlg" style="display: none">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">清空日志</h4>
            </div>
            <div class="modal-body">
                <form id="form1">
                    <div class="form-group">
                        <select class="form-control required" id="keepTime" name="keepTime" required>
                            <option value="">==请选择保留时间==</option>
                            <option value="7">保留近一周</option>
                            <option value="1">保留近一个月</option>
                            <option value="3">保留近三个月</option>
                            <option value="0">不保留，全部删除</option>
                        </select>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
                <button type="button" onclick="removelog()" class="btn btn-primary">确认</button>
            </div>
        </div>
    </div>
</div>

<div id="loadingPage" style="display: none;">
    <div class="loading-shade"></div>
    <div class="loading-content" onclick="$.loading(false)">数据加载中，请稍后…</div>
</div>
@section Scripts {
    <script type="text/javascript">
        $(document).ready(function () {
            $('#footable').footable();
        });

        var timeType = document.getElementById("timeType").value;

        $("#time_horizon button.btn-default").each(function () {
            if (!timeType) {
                timeType = "2";
            }
            if (timeType == $(this).attr('data-value')) {
                $("#time_horizon button.btn-default").removeClass("active");
                $(this).addClass("active");
            }
        });

        $("#time_horizon button.btn-default").click(function () {
            $("#time_horizon button.btn-default").removeClass("active");
            $(this).addClass("active");
            $('#btn_search').trigger("click");
        });

        $("#btn_search").click(function () {
            var timeType = $("#time_horizon button.active").attr('data-value');
            var keyword = $("#filter").val();
            window.location.href = "/LogInlog/Index?keyword=" + keyword + "&timeType=" + timeType;
        });

        function btn_removelog() {
            $('#removeDlg').modal();
        }

        function removelog() {
            if (!$('#form1').formValid()) {
                return false;
            }
            $.submitForm({
                loading: "正在备份数据...",
                url: "/LogInLog/SubmitRemoveLog",
                param: $("#form1").formSerialize(),
                success: function () {
                    $('#removeDlg').modal("hide");
                }
            })
        }
    </script>
}






